package com.nopay.dxdwphone.bean;

import java.io.Serializable;

/**
 * @ProjectName: myVisualPhone
 * @Package: cn.cn.myvisualphone.bean
 * @ClassName: PersonInfoBean
 * @Description: java类作用描述
 * @Author: anqi
 * @CreateDate: 2021/6/1 14:15
 * @UpdateUser: 更新者
 * @UpdateDate: 2021/6/1 14:15
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class PersonInfoBean implements Serializable, Comparable<PersonInfoBean> {

    private String companyName;
    private String personName;
    private String tel;

    public PersonInfoBean() {
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getPersonName() {
        return personName;
    }

    public void setPersonName(String personName) {
        this.personName = personName;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @Override
    public String toString() {
        return "PersonInfoBean{" +
                "companyName='" + companyName + '\'' +
                ", personName='" + personName + '\'' +
                ", tel='" + tel + '\'' +
                '}';
    }

    @Override
    public int compareTo(PersonInfoBean o) {
        //如果是基本数据类型直接用==判断，String用equal，实际上走的hash
        if (this.tel.equals(o.tel)) {
            return 0;
        } else {
            return -1;
        }
    }

    @Override
    public boolean equals(Object o) {
        //如果两个对象地址一样认为相等
        if (this == o) {
            return true;
        }
        //如果上个对象为空，且类名不相同
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        PersonInfoBean infoBean = (PersonInfoBean) o;

        if (companyName != null ? !companyName.equals(infoBean.companyName) : infoBean.companyName != null) {
            return false;
        }

        if (personName != null ? !personName.equals(infoBean.personName) : infoBean.personName != null) {
            return false;
        }
        //多个指标从上往下扫描,如果某个字段空，other字段也为空才行，如果是基本数据类型直接用!=判断
        return tel != null ? tel.equals(infoBean.tel) : infoBean.tel == null;
    }

    @Override
    public int hashCode() {
        int result = companyName != null ? companyName.hashCode() : 0;
        result = 31 * result + (personName != null ? personName.hashCode() : 0);
        result = 31 * result + (tel != null ? tel.hashCode() : 0);
        return result;
    }

}
